"""
@Project:che
@File:model.py
@Author:马可
@Date:上午 10:36
"""
from flask_sqlalchemy import SQLAlchemy
from _datetime import datetime
db = SQLAlchemy()

# 用户
class User(db.Model):
    id = db.Column(db.Integer,primary_key=True,autoincrement=True,comment="用户id")
    plate = db.Column(db.String(32),comment="车牌号")
    type = db.Column(db.String(32),default="没包月",comment="类型（是否包月）")
    cost = db.Column(db.String(500), default='0', comment="金额")

# 价格
class Cost(db.Model):
    id = db.Column(db.Integer,primary_key=True,autoincrement=True,comment="费用id")
    type = db.Column(db.String(32),comment="类型（是否业主）")
    cost = db.Column(db.String(500),default='0',comment="金额")
    plate_id = db.Column(db.Integer,db.ForeignKey("user.id"),comment="所属车牌")

# 记录
class Take(db.Model):
    id = db.Column(db.Integer,primary_key=True,autoincrement=True,comment="记录id")
    plate_id = db.Column(db.Integer,db.ForeignKey("user.id"),comment="所属车牌")
    create_time = db.Column(db.DateTime,default=datetime.now,comment="进入时间")
    end_time = db.Column(db.DateTime,default=datetime.now,comment="离开时间")
    cost = db.Column(db.String(500),default='0',comment="金额")
